package com.sd.springboot.experiment_1.config;

import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.GsonHttpMessageConverter;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@Configuration
public class MyMessageConverterConfig {

    @Bean
    public HttpMessageConverters myHttpMessageConverters() {
        List<HttpMessageConverter<?>> messageConverters = new ArrayList<>();

        GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter();
        messageConverters.add(gsonHttpMessageConverter);

        // 将新加入的消息转换器设置为默认消息格式转换器
        return new HttpMessageConverters(true, messageConverters);
    }


}
